package com.nantian.nfcm.bms.loan.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.nantian.nfcm.bms.loan.entity.ApprovalPower;
import org.springframework.stereotype.Repository;

@Repository
public interface ApprovalPowerDao extends JpaRepository<ApprovalPower, Long>, JpaSpecificationExecutor<ApprovalPower> {
	
	/**
	 * 根据指定参数查询贷款权限
	 * @param loanType 贷款类型
	 * @param loanGuarantee 贷款担保方式
	 * @return
	 */
	@Query("from ApprovalPower ap where ap.loanType=?1 and ap.loanGuarantee=?2 and ap.loanSubType is null")
	public List<ApprovalPower> findByParam(String loanType, String loanGuarantee);

	/**
	 * 根据指定参数查询贷款权限
	 * @param loanType 贷款类型
	 * @param loanSubType 贷款子类型
	 * @param loanGuarantee 贷款担保方式
	 * @return
	 */
	@Query("from ApprovalPower ap where ap.loanType=?1 and ap.loanSubType=?2 and ap.loanGuarantee=?3")
	public List<ApprovalPower> findByParam(String loanType,String loanSubType, String loanGuarantee);
}
